package com.ten.security.utils;

import com.ten.common.core.util.JWTUtil;

import java.util.Map;

/**
 * @author ：Q大侠
 * @date ：Created in 2022/12/4 6:36
 * @description：获取已登陆的用户名
 * @modified By：
 * @version:
 */
public class TokenToAll {
    /** 
     * @create by:  Q大侠
     * @description: 通过token获取当前登录用户的名称 
     * @create time: 2022/12/4 6:43
      * @param
     * @return username 
     */
    public static String ToName(){
        String token = WebUtil.getRequest().getHeader("token");
        Map<String, Object> map = JWTUtil.getTokenChaim(token);
        String username = (String) map.get("username");
        return username;
    }
}
